package com.example.educationplatformbackend.utils;


import lombok.AllArgsConstructor;
import lombok.Data;
import org.springframework.http.HttpStatus;

@Data
public class ResponseResult<T> {
    private int code;
    private String message;
    private T data;


    public ResponseResult(int code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public static <T> ResponseResult<T> success(T data) {
        return new ResponseResult<>(HttpStatus.OK.value(), "成功", data);
    }

    public static <T> ResponseResult<T> failure(HttpStatus status, String message) {
        return new ResponseResult<>(status.value(), message, null);
    }

}